package com.example.myandroidapp1.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.example.myandroidapp1.GalleryViewActivity;
import com.example.myandroidapp1.R;
import com.example.myandroidapp1.dto.ImageLoader;
import com.example.myandroidapp1.entity.Gallery;

public class GalleryAdapter extends BaseAdapter {
	
	private Context context;
	private View gridView;
	private Gallery gallery;

	public GalleryAdapter(GalleryViewActivity context, Gallery gallery) {
		this.context = context;
		this.gallery = gallery;
	}

	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		if (convertView == null) {

			gridView = new View(context);
			gridView = inflater.inflate(R.layout.gridviewdata, null);
			// initialize();
			TextView hiddenTextView = (TextView) gridView.findViewById(R.id.tvGridItemHidden);
			ImageView imageView = (ImageView) gridView.findViewById(R.id.grid_item_image);
			ProgressBar progressBar = (ProgressBar) gridView.findViewById(R.id.pbImage);

			// textView.setText(mobileValues[position]);
			new ImageLoader(imageView, progressBar, hiddenTextView).execute(gallery.getImageList().get(position).getThumbnail());

		} else {
			gridView = (View) convertView;
		}

		return gridView;
	}

	@Override
	public int getCount() {
		return gallery.getImageList().size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}



}
